<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta
      http-equiv="Cache-Control"
      content="no-cache, no-store, must-revalidate"
    />
    <meta http-equiv="Cache" content="no-cache" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <link
      rel="stylesheet"
      href="https://kendo.cdn.telerik.com/2021.3.1207/styles/kendo.default-v2.min.css"
    />
    <script src="https://unpkg.com/vue@next"></script>
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <script src="https://kendo.cdn.telerik.com/2021.3.1207/js/kendo.all.min.js"></script>
    <title>鼠标跟踪</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      body {
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: #eed9eba9;
      }
      .shell {
        display: grid;
        grid-template-columns: repeat(7, 40px);
        grid-template-rows: repeat(7, 40px);
        grid-gap: 1.5rem;
      }
      .item {
        background-color: rgb(40, 40, 40);
        border-radius: 5px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
        border-left: solid 10px #fff;
      }
      .item::after,
      .item::before {
        content: "";
        width: 5px;
        height: 5px;
        display: block;
        position: absolute;
        border-radius: 50%;
        left: 20px;
        background-color: #fff;
      }
      .item::after {
        top: 25px;
      }
      .item::before {
        bottom: 25px;
      }
    </style>
  </head>
  <body>
    <div class="shell">
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
    </div>
    <script>
      document.addEventListener("mousemove", (e) => {
        const item = document.querySelectorAll(".item");
        const mouseX = e.clientX;
        const mouseY = e.clientY;

        item.forEach((sqr) => {
          const sqrX = sqr.offsetLeft;
          const sqrY = sqr.offsetTop;
          const diffX = mouseX - sqrX;
          const diffY = mouseY - sqrY;
          const radians = Math.atan2(diffY, diffX);
          const angle = (radians * 180) / Math.PI;
          sqr.style.transform = `rotate(${angle}deg)`;
        });
      });
    </script>
  </body>
</html>
